package com.rmt.www.action;


import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.rmt.www.constant.RequestType;
import com.rmt.www.dao.ArtifactDao;
import com.rmt.www.dao.ProjectDao;
import com.rmt.www.dao.RequestDao;
import com.rmt.www.dao.UserDao;
import com.rmt.www.service.DevManageDesignService;
import com.rmt.www.vo.Artifact;
import com.rmt.www.vo.DesignArtifactRequest;
import com.rmt.www.vo.Project;
import com.rmt.www.vo.Request;
import com.rmt.www.vo.User;


public class AddDesignAction extends ActionSupport{
	private int pid;
	private String title;
	private String priority;
	private String effort;
	private String cost;
	private String risk;
	private String comment;
	private int createrid;
	private Timestamp createdtime;
	private int updaterid;
	private Timestamp updatedtime;
	private int updatedtimes;
	private String version;
	private String status;
	private String architect;
	private String consideration;
	private String input;
	private String function;
	private String output;
	private String perfrequest;
	private String securityrequest;
	private String storagerequest;
	private String innerinterface;
	private String outerinterface;
	private DevManageDesignService devManageDesignService;
	

	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public DevManageDesignService getDevManageDesignService() {
		return devManageDesignService;
	}
	public void setDevManageDesignService(
			DevManageDesignService devManageDesignService) {
		this.devManageDesignService = devManageDesignService;
	}
	
	public int getPid() {
		return pid;
	}
	public void setPid(int pid) {
		this.pid = pid;
	}
	public String getPriority() {
		return priority;
	}
	public void setPriority(String priority) {
		this.priority = priority;
	}
	public String getEffort() {
		return effort;
	}
	public void setEffort(String effort) {
		this.effort = effort;
	}
	public String getCost() {
		return cost;
	}
	public void setCost(String cost) {
		this.cost = cost;
	}
	public String getRisk() {
		return risk;
	}
	public void setRisk(String risk) {
		this.risk = risk;
	}
	public String getComment() {
		return comment;
	}
	public void setComment(String comment) {
		this.comment = comment;
	}
	public int getCreaterid() {
		return createrid;
	}
	public void setCreaterid(int createrid) {
		this.createrid = createrid;
	}
	public Timestamp getCreatedtime() {
		return createdtime;
	}
	public void setCreatedtime(Timestamp createdtime) {
		this.createdtime = createdtime;
	}
	public int getUpdaterid() {
		return updaterid;
	}
	public void setUpdaterid(int updaterid) {
		this.updaterid = updaterid;
	}
	public Timestamp getUpdatedtime() {
		return updatedtime;
	}
	public void setUpdatedtime(Timestamp updatedtime) {
		this.updatedtime = updatedtime;
	}
	public int getUpdatedtimes() {
		return updatedtimes;
	}
	public void setUpdatedtimes(int updatedtimes) {
		this.updatedtimes = updatedtimes;
	}
	public String getVersion() {
		return version;
	}
	public void setVersion(String version) {
		this.version = version;
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	public String getArchitect() {
		return architect;
	}
	public void setArchitect(String architect) {
		this.architect = architect;
	}
	public String getConsideration() {
		return consideration;
	}
	public void setConsideration(String consideration) {
		this.consideration = consideration;
	}
	public String getInput() {
		return input;
	}
	public void setInput(String input) {
		this.input = input;
	}
	public String getFunction() {
		return function;
	}
	public void setFunction(String function) {
		this.function = function;
	}
	public String getOutput() {
		return output;
	}
	public void setOutput(String output) {
		this.output = output;
	}
	public String getPerfrequest() {
		return perfrequest;
	}
	public void setPerfrequest(String perfrequest) {
		this.perfrequest = perfrequest;
	}
	public String getSecurityrequest() {
		return securityrequest;
	}
	public void setSecurityrequest(String securityrequest) {
		this.securityrequest = securityrequest;
	}
	public String getStoragerequest() {
		return storagerequest;
	}
	public void setStoragerequest(String storagerequest) {
		this.storagerequest = storagerequest;
	}
	public String getInnerinterface() {
		return innerinterface;
	}
	public void setInnerinterface(String innerinterface) {
		this.innerinterface = innerinterface;
	}
	public String getOuterinterface() {
		return outerinterface;
	}
	public void setOuterinterface(String outerinterface) {
		this.outerinterface = outerinterface;
	}
	public String execute(){
		DesignArtifactRequest r = new DesignArtifactRequest();
		r.setPid(pid);
		r.setTitle(title);
		r.setPriority(priority);
		r.setArchitect(architect);
		r.setEffort(Integer.parseInt(effort));
		r.setCost(cost);
		r.setRisk(risk);
		r.setComment(comment);
		r.setUpdatedtimes(0);
		r.setVersion(version);
		r.setStatus(status);
		r.setConsideration(consideration);
		r.setInput(input);
		r.setFunction(function);
		r.setOutput(output);
		r.setPerfrequest(perfrequest);
		r.setSecurityrequest(securityrequest);
		r.setStoragerequest(storagerequest);
		r.setInnerinterface(innerinterface);
		r.setOuterinterface(outerinterface);
		r.setRequesttype(RequestType.ADD);
		User u=(User)ActionContext.getContext().getSession().get("currentUser");
		r.setCreaterid(u.getUid());
		devManageDesignService.addNewDesignRequest(r);
		
		return "success";
		
	}
}
